#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2017/8/26 上午12:01
# @Author  : Liujiaqi
# @Site    : 
# @File    : DBUtilsTools.py
# @Software: PyCharm


import MySQLdb
from DBUtils.PooledDB import PooledDB

class DBPool():

    def __init__(self):
        self.pool = PooledDB(MySQLdb,5,host='192.168.1.104',user='root',passwd='123465',db='zeus',port=3306) #5为连接池里的最少连接数

    def getConnection(self):
        return self.pool.connection()


class DBSingle():

    def __init__(self,host,port,user,password,dbname=''):
        self.host = host
        self.port = port
        self.user = user
        self.password = password
        self.dbname = dbname

    def getConnection(self):
         conn = MySQLdb.connect(host=self.host,port=int(self.port),user=self.user,passwd=self.password)
         return conn
